<%= render Polaris::BaseComponent.new(**system_arguments) do %>
  <% if tabs.present? %>
    <%= tabs %>
  <% end %>

  <% if header.present? %>
    <%= header %>
  <% end %>

  <% if @title.present? && !header.present? %>
    <%= render Polaris::Card::HeaderComponent.new(title: @title, actions: @actions) %>
  <% end %>

  <% if sections.present? %>
    <% sections.each do |section| %>
      <%= section %>
    <% end %>
  <% end %>

  <% if content.present? %>
    <% if @sectioned %>
      <%= render Polaris::Card::SectionComponent.new do %>
        <%= content %>
      <% end %>
    <% else %>
      <%= content %>
    <% end %>
  <% end %>

  <% if render_footer? %>
    <div class="<%= footer_classes %>">
      <%= polaris_button_group do |group| %>
        <% if @footer_action_alignment == :right %>
          <% secondary_footer_actions.each do |secondary_footer_action| %>
            <% group.with_item do %>
              <%= secondary_footer_action %>
            <% end %>
          <% end %>

          <% if primary_footer_action %>
            <% group.with_item do %>
              <%= primary_footer_action %>
            <% end %>
          <% end %>
        <% else %>
          <% if primary_footer_action %>
            <% group.with_item do %>
              <%= primary_footer_action %>
            <% end %>
          <% end %>

          <% secondary_footer_actions.each do |secondary_footer_action| %>
            <% group.with_item do %>
              <%= secondary_footer_action %>
            <% end %>
          <% end %>
        <% end %>
      <% end %>
    </div>
  <% end %>
<% end %>
